﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZLDC.Common.Estate;
using System.Data;

namespace ZLDC.Topo.BLL.Estate
{
    public class CallBoardBLL
    {
                public static string p_call_board_save(int msg_id, string msg_title, string content, int msg_type, string reader)
        {
            string outmsg = "";
            int newid = 0;
            int userId = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string deptName = _Utility.GetInfoBySession().m_sDeptName;
            string userName = _Utility.GetInfoBySession().m_sUserName;

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.CallBoardDAL.p_call_board_save(msg_id, msg_title, content, userId, userName, deptName, msg_type, reader, out outmsg, out newid, db);
            }

            return outmsg;
        }


        public static void DeleteMsg()
        {
            int userId = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.CallBoardDAL.DeleteMsg(userId, db);
            }
        }
        public static void DeleteMsgList() 
        {
            using (_Database db = new _Database("estate")) 
            {
                ZLDC.DAL.Estate.CallBoardDAL.DeleteMsg(db);
            }
        }

                public static string p_call_board_list_table(int page, int pagesize, string condition)
        {
            DataTable dt = null;
            int total = 0;                       int pageall = 0;         
            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.CallBoardDAL.p_call_board_list_table(page, pagesize, condition, ref total, db);
            }

            pageall = _Utility.GetPageAll(pagesize, total);      
            _Json json = new _Json(dt);

            return "{page:{currentpage:'" + page + "',pagesize:'" + pagesize + "',total:'" + total + "',pageall:'" + pageall + "'},record:" + json.ToJson() + "}";

        }
                public static DataSet SelectDetailsById(int id)
        {
            using (_Database db = new _Database("estate")) 
            {
                return ZLDC.DAL.Estate.CallBoardDAL.SelectDetailsByID(id,db);
            }
        }
                public static string DeleteCallBoard(int id)
        {
            using (_Database db = new _Database("estate")) 
            {
                return ZLDC.DAL.Estate.CallBoardDAL.DeleteCallBoard(id, db).ToString();
            }
        }
                public static string GetNewTopInfo()
        {
            using (_Database db = new _Database("estate")) 
            {
                return ZLDC.DAL.Estate.CallBoardDAL.GetNewTopInfo(db);
            }
        }
    }
}
